package com.hhkj.study.admin.user.service.base.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hhkj.study.admin.user.entity.UserExercise;
import com.hhkj.study.admin.user.mapper.UserExerciseMapper;
import com.hhkj.study.admin.user.model.podo.UserExerciseDo;
import com.hhkj.study.admin.user.model.podo.UserExercisePo;
import com.hhkj.study.admin.user.service.base.UserExerciseService;
import com.ruoyi.common.base.biz.service.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
*
* @author SERVER
* @since 2024-09-06
*/
@Service
public class UserExerciseServiceImpl extends BaseServiceImpl<UserExercise, UserExerciseDo, UserExercisePo, UserExerciseMapper> implements UserExerciseService {

    @Override
    public List<UserExercise> listByUserCourse(Long userId, Long courseId, Long orderItemId, Long type) {
        LambdaQueryWrapper<UserExercise> userExerciseQuery = new LambdaQueryWrapper<>();
        userExerciseQuery.eq(UserExercise::getUserId, userId).eq(UserExercise::getCourseId, courseId)
                .eq(UserExercise::getOrderItemId, orderItemId).eq(ObjectUtil.isNotNull(type), UserExercise::getBankType, type);
        return this.list(userExerciseQuery);
    }
}